package com.titar.robot.utils;

import android.view.View;
import android.widget.TextView;

import com.titar.robot.R;


/**
 * @project： TimotechDolphin_Android
 * @package： com.timotech.watch.timo.utils
 * @class: TipBarUtil
 * @author: 陆伟
 * @Date: 2017/11/17 14:52
 * @desc： TODO
 */

public class TipBarUtil {
    private View mTipBar;
    private TextView mTvTip;
    private View mBtnClose;

    public TipBarUtil(View tipBar) {
        mTipBar = tipBar.findViewById(R.id.tip_bar);
        mTvTip = (TextView) tipBar.findViewById(R.id.tip_tv_text);
        mBtnClose = tipBar.findViewById(R.id.tip_btn_close);
        mBtnClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                close();
            }
        });
    }

    public void tipError(String tipMsg) {
        tip(tipMsg, 0xfff6383a);
    }

    public void tipWarm(String tipMsg) {
        tip(tipMsg, 0xffff6600);
    }

    public void tip(String tipMsg, int bgColor) {
        if (mTipBar == null) {
            return;
        }
        mTvTip.setText(tipMsg);
        mTipBar.setBackgroundColor(bgColor);
        mTipBar.setVisibility(View.VISIBLE);
    }

    public void close() {
        if (mTipBar == null) {
            return;
        }
        mTipBar.setVisibility(View.GONE);
    }
}
